package com.dl.order.controller;

import com.dl.pojo.CommonResult;
import com.dl.pojo.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @ProjectName: mcroservices
 * @Package: com.dl.order.controller
 * @ClassName: OrderController
 * @Author: 86977
 * @Description: ${description}
 * @Date: 2021/6/23 21:52
 * @Version: 1.0
 */

@RestController
@Slf4j
public class OrderController {
  //调用支付订单服务端的ip+端口号
  public static final  String PAYMENT_URL = "http://localhost:9903";

  @Autowired
  private RestTemplate restTemplate;
  //创建支付订单的接口
  @GetMapping("/consumer/payment/create")
  public CommonResult<Payment> create(Payment payment){
    return restTemplate.postForObject(PAYMENT_URL+"/payment/create",payment, CommonResult.class);
  }
  //获取id获取支付订单
  @GetMapping("/consumer/payment/get/{id}")
  public CommonResult<Payment> getPayment(@PathVariable("id") Long id){
    return restTemplate.getForObject(PAYMENT_URL+"/payment/get/"+id,CommonResult.class);
  }


}
